package com.example.javapoint.threads.join;

class ThreadJoin2 extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName() + "=====>" + i);
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class ThreadJoinExample2 {
    public static void main(String[] args) {
        ThreadJoin2 th1 = new ThreadJoin2();
        ThreadJoin2 th2 = new ThreadJoin2();
        ThreadJoin2 th3 = new ThreadJoin2();
        th1.start();
        try {
            th1.join(1500);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        th2.start();
        th3.start();
    }
}
